﻿namespace Guru.Framework.Util
{
    using System;

    public class ConverterUtil
    {
        public static int Convert2Int(string willBeConverted)
        {
            try
            {
                return int.Parse(willBeConverted);
            }
            catch (Exception)
            {
                return 0;
            }
        }

        public static DateTime ConvertString2DateTime(string date_time)
        {
            try
            {
                return DateTime.Parse(date_time);
            }
            catch (Exception)
            {
                return new DateTime(1900, 1, 1, 0, 0, 0);
            }
        }

        public static int Convert2Int(object willBeConverted)
        {
            try
            {
                return Convert.ToInt32(willBeConverted);
            }
            catch (Exception)
            {
                return 0;
            }
        }

        public static double Convert2Double(string willBeConverted)
        {
            try
            {
                return double.Parse(willBeConverted);
            }
            catch (Exception)
            {
                return 0.0d;
            }
        }

        public static double Convert2Double(object willBeConverted)
        {
            try
            {
                return Convert.ToDouble(willBeConverted);
            }
            catch (Exception)
            {
                return 0.0d;
            }
        }


    }
}
